package com.zhihaoliang.map.home

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.zhihaoliang.map.R
import com.zhihaoliang.map.base.SimpleUserInput
import com.zhihaoliang.map.ui.theme.CraneTheme

/**
 * @author 支豪亮
 * @date 2023/1/12 16:41
 */

/**
 *  FLy页面 低部页面，搜索数据设置
 *  @param onPeopleChanged 当人同行人数的变化时的回调
 *  @param onToDestinationChanged 当目的变化时的回调
 */
@Composable
fun FlySearchContent(onPeopleChanged: (Int) -> Unit, onToDestinationChanged: (String) -> Unit) {
    CraneSearch {
        PeopleUserInput( titleSuffix = ", Economy", onPeopleChanged = onPeopleChanged )
        Spacer(Modifier.height(8.dp))
        FromDestination()
        Spacer(Modifier.height(8.dp))
        ToDestinationUserInput(onToDestinationChanged = onToDestinationChanged)
        Spacer(Modifier.height(8.dp))
        DatesUserInput()
    }
}

/**
 *  Sleep页面 低部页面，搜索数据设置
 *  @param onPeopleChanged 当人同行人数的变化时的回调
 */
@Composable
fun SleepSearchContent(onPeopleChanged: (Int) -> Unit) {
    CraneSearch {
        PeopleUserInput(onPeopleChanged = onPeopleChanged)
        Spacer(modifier = Modifier.height(8.dp))
        DatesUserInput()
        Spacer(modifier = Modifier.height(8.dp))
        SimpleUserInput(caption = "Select Location", vectorImageId = R.drawable.ic_hotel)
    }
}

/**
 *  Eat页面 低部页面，搜索数据设置
 *  @param onPeopleChanged 当人同行人数的变化时的回调
 */
@Composable
fun EatSearchContent(onPeopleChanged: (Int) -> Unit) {
    CraneSearch {
        PeopleUserInput(onPeopleChanged = onPeopleChanged)
        Spacer(modifier = Modifier.height(8.dp))
        DatesUserInput()
        Spacer(modifier = Modifier.height(8.dp))
        SimpleUserInput(caption = "Select Time", vectorImageId = R.drawable.ic_time)
        Spacer(modifier = Modifier.height(8.dp))
        SimpleUserInput(caption = "Select Location", vectorImageId = R.drawable.ic_restaurant)
    }
}

/**
 * 搜索页面的变间距的设置
 * @param content 设置页面的内容
 */
@Composable
private fun CraneSearch(content: @Composable () -> Unit) {
    Column(Modifier.padding(start = 24.dp, top = 0.dp, end = 24.dp, bottom = 12.dp)) {
        content()
    }
}

@Composable
@Preview
fun FlySearchContentPreview() {
    CraneTheme {
        FlySearchContent({}, {})
    }

}

@Composable
@Preview
fun SleepSearchContentPreview() {
    CraneTheme {
        SleepSearchContent({})
    }
}

@Composable
@Preview
fun EatSearchContentPreview() {
    CraneTheme {
        EatSearchContent({})
    }
}

